 <script language="javascript">
function validate_form(thisform)
{
with (thisform)
{
	
	
	if (validate_required(txtmonth,"Bạn chưa chọn tháng !")==false)
 	{txtmonth.focus();return false;}
	
	if (validate_required(txtyear,"Bạn chưa chọn năm !")==false)
 	{txtyear.focus();return false;}
	if (validate_required(nhanvien,"Bạn chưa chọn nhân viên !")==false)
 	{nhanvien.focus();return false;}
	

}
}
</script>
 <table class="box-vang5" cellpadding="0" cellspacing="0" width="100%">
        <tbody><tr class="light">
          <td class="text-top">.:. Chi tiết lịch làm việc</td>
        </tr>
      </tbody></table>
      <table class="box-vang5" cellpadding="0" cellspacing="0" width="100%">
        <tbody><tr class="light">
          <td class="t-l"></td>
          <td class="t-c"></td>
          <td class="t-r"></td>
        </tr>
        <tr class="light">
          <td class="c-l"></td>
          <td class="c-c" valign="top">
  
<div class="clear" style="height:10px"></div>
<div id="noidung-tab1">
	<form method="post" action="" onsubmit="return validate_form(this);">
     <p>Xem kế hoạch công việc tháng  <span>
     	<select name="txtmonth"> 
        	<option value="">--Chọn tháng--</option>
            <option value="01" <?php if($_POST['txtmonth']==1){?> selected="selected" <?php }?>> 01 </option>
            <option value="02" <?php if($_POST['txtmonth']==2){?> selected="selected" <?php }?>> 02 </option>
            <option value="03" <?php if($_POST['txtmonth']==3){?> selected="selected" <?php }?>> 03 </option>
            <option value="04" <?php if($_POST['txtmonth']==4){?> selected="selected" <?php }?>> 04 </option>
            <option value="05" <?php if($_POST['txtmonth']==5){?> selected="selected" <?php }?>> 05 </option>
            <option value="06" <?php if($_POST['txtmonth']==6){?> selected="selected" <?php }?>> 06 </option>
            <option value="07" <?php if($_POST['txtmonth']==7){?> selected="selected" <?php }?>> 07 </option>
            <option value="08" <?php if($_POST['txtmonth']==8){?> selected="selected" <?php }?>> 08 </option>
            <option value="09" <?php if($_POST['txtmonth']==9){?> selected="selected" <?php }?>> 09 </option>
            <option value="10" <?php if($_POST['txtmonth']==10){?> selected="selected" <?php }?>> 10 </option>
            <option value="11" <?php if($_POST['txtmonth']==11){?> selected="selected" <?php }?>> 11 </option>
            <option value="12" <?php if($_POST['txtmonth']==12){?> selected="selected" <?php }?>> 12 </option>
        </select>
    </span> 
    <span>Năm </span> 
    <span> 
    	<select name="txtyear"> 
        	<option value="">--Chọn năm--</option>
            <option value="2012" <?php if($_POST['txtyear']==2012){?> selected="selected" <?php }?>>2012 </option>
            <option value="2013" <?php if($_POST['txtyear']==2013){?> selected="selected" <?php }?>>2013 </option>
            <option value="2014" <?php if($_POST['txtyear']==2014){?> selected="selected" <?php }?>>2014 </option>
            <option value="2015" <?php if($_POST['txtyear']==2015){?> selected="selected" <?php }?>>2015 </option>
            <option value="2016" <?php if($_POST['txtyear']==2016){?> selected="selected" <?php }?>>2016 </option>
            <option value="2017" <?php if($_POST['txtyear']==2017){?> selected="selected" <?php }?>>2017 </option>
            <option value="2018" <?php if($_POST['txtyear']==2018){?> selected="selected" <?php }?>>2018 </option>
            <option value="2019" <?php if($_POST['txtyear']==2019){?> selected="selected" <?php }?>>2019 </option>
            <option value="2020" <?php if($_POST['txtyear']==2020){?> selected="selected" <?php }?>>2020 </option>
        </select>
    </span> 
    <?php if($_SESSION['level']==2 or $_SESSION['level']==3){?>
    &nbsp;&nbsp;
    |
    &nbsp;&nbsp;
    <span>Nhân viên </span> 
    <span> 
    	<select name="nhanvien"> 
        	<option value="">--Chọn nhân viên--</option>
            <?php 
				$sqlnhanvien=mysql_query("select * from tb_account_admin where level!=3");
				while($rsnhanvien=mysql_fetch_array($sqlnhanvien))
				{
			?>
            <option value="<?php echo $rsnhanvien['account_id'];?>" <?php if($_POST['nhanvien']==$rsnhanvien['account_id']){?> selected="selected" <?php }?>><?php echo $rsnhanvien['account_name'];?></option>
           <?php }?>
        </select>
    </span> 
    <?php }?>
    &nbsp;
    <span><input name="button" type="submit" value="Tìm kiếm" class="cs-title-timkiem"/></span>
    &nbsp;&nbsp;
    	
    </p>
    
    </form>
    <div class="clear" style="height:10px"></div>
      <div class="cont-table-lich">
      <table width="100%" class="bang-baocao-llv" border="1">
  <tr align="center" style="font-weight:bold;">
  	<td  bgcolor="#92d050" style="width:3%; height:20px;" rowspan="2">STT</td>
    <td  bgcolor="#92d050" style="width:300px; height:20px;" rowspan="2">Công việc</td>
    <td colspan="31" bgcolor="#92d050">
    <?php 
		$txtmonth=$_POST['txtmonth'];
		$txtyear=$_POST['txtyear'];
		$nhanvien=$_POST['nhanvien'];
	?>
    	Tháng <?php if($txtmonth!="" and $txtyear!=""){echo $txtmonth.'/'.$txtyear;}else {echo date('m/Y',time());}?>
     </td>
   
  </tr>
  <tr align="center">
 
  <?php 
  	$today=date('d',time());
  	for($j=1;$j<=31;$j++)
	{
  ?>
    <td <?php if($j==$today){echo 'bgcolor="#ff0"';}else {echo 'bgcolor="#00b0f0"';}?> class="ovuong"><?php echo $j;?></td>
   
    <?php }?>
  </tr>
  <?php 
  	 $month=date('m',time());
	 $year=date('Y',time());
  	$user=$_SESSION['userid'];
  	$sqlstring="
					select * 
					from 
						register
						inner join tb_task on register.task_id= tb_task.task_id
					where recipient='$user' and month='$month' and year='$year' and (giahan=0 or giahan=2) and (duyet_phatsinh=0 or duyet_phatsinh=2)
					
					";
	$sqlstring2="
					select * 
					from 
						register
						inner join tb_task on register.task_id= tb_task.task_id
					where recipient='$user' and (giahan=0 or giahan=2) and (duyet_phatsinh=0 or duyet_phatsinh=2)
					
					";
	$sqlstring3="
					select * 
					from 
						register
						inner join tb_task on register.task_id= tb_task.task_id
				
					";
	if($_SESSION['level']!==2 and $_SESSION['level']!==3)
	{
		if($txtmonth!="" and $txtyear!=""){$sqlstring2.=" and month like '%$txtmonth%' and year like '%$txtyear%'";}
		if($txtmonth!="" and $txtyear!="")
		{
		$sql=mysql_query($sqlstring2);
		}
		else
		{
			$sql=mysql_query($sqlstring);
		}
	}
	if($_SESSION['level']==2 or $_SESSION['level']==3)
	{
		if($txtmonth!="" and $txtyear!="" and $nhanvien!="")
		{
			$sqlstring3.=" and month like '%$txtmonth%' and year like '%$txtyear%' and recipient ='$nhanvien' and (giahan=0 or giahan=2) and (duyet_phatsinh=0 or duyet_phatsinh=2)";
		}
		if($txtmonth!="" and $txtyear!="" and $nhanvien!="")
		{
			$sql=mysql_query($sqlstring3);
		}
	}
	
  ?>
  
  <?php
  	$dem=1; 
  	while($row=mysql_fetch_array($sql))
	{
		?>
  <tr align="center">
  	<td><?php echo $dem++;?> </td>
    <td align="left" style="padding-left:10px; cursor:pointer" class="ovuong" onclick="window.open('index.php?tn=task_detail&id=<?php echo $row['task_id'];?>','_self');"><strong> <?php echo $row['task_name'];?></strong>&nbsp; <span style="color:#f00"><?php if($row['giahan']==2){echo 'gia hạn thêm';}?> </span></td>
    <td <?php if($row['date1']==1){ echo 'style="background-color:#090"'; }?>></td>     
   	<td <?php if($row['date2']==2){ echo 'style="background-color:#090"'; }?>></td>
    <td <?php if($row['date3']==3){ echo 'style="background-color:#090"'; }?>></td>
    <td <?php if($row['date4']==4){ echo 'style="background-color:#090"'; }?>></td>
    <td <?php if($row['date5']==5){ echo 'style="background-color:#090"'; }?>></td>
    <td <?php if($row['date6']==6){ echo 'style="background-color:#090"'; }?>></td>
    <td <?php if($row['date7']==7){ echo 'style="background-color:#090"'; }?>></td>
    <td <?php if($row['date8']==8){ echo 'style="background-color:#090"'; }?>></td>
    <td <?php if($row['date9']==9){ echo 'style="background-color:#090"'; }?>></td>
    <td <?php if($row['date10']==10){ echo 'style="background-color:#090"'; }?>></td>
    <td <?php if($row['date11']==11){ echo 'style="background-color:#090"'; }?>></td>
    <td <?php if($row['date12']==12){ echo 'style="background-color:#090"'; }?>></td>
    <td <?php if($row['date13']==13){ echo 'style="background-color:#090"'; }?>></td>
    <td <?php if($row['date14']==14){ echo 'style="background-color:#090"'; }?>></td>
    <td <?php if($row['date15']==15){ echo 'style="background-color:#090"'; }?>></td>
    <td <?php if($row['date16']==16){ echo 'style="background-color:#090"'; }?>></td>
    <td <?php if($row['date17']==17){ echo 'style="background-color:#090"'; }?>></td>
    <td <?php if($row['date18']==18){ echo 'style="background-color:#090"'; }?>></td>
    <td <?php if($row['date19']==19){ echo 'style="background-color:#090"'; }?>></td>
    <td <?php if($row['date20']==20){ echo 'style="background-color:#090"'; }?>></td>
    <td <?php if($row['date21']==21){ echo 'style="background-color:#090"'; }?>></td>
    <td <?php if($row['date22']==22){ echo 'style="background-color:#090"'; }?>></td>
    <td <?php if($row['date23']==23){ echo 'style="background-color:#090"'; }?>></td>
    <td <?php if($row['date24']==24){ echo 'style="background-color:#090"'; }?>></td>
    <td <?php if($row['date25']==25){ echo 'style="background-color:#090"'; }?>></td>
    <td <?php if($row['date26']==26){ echo 'style="background-color:#090"'; }?>></td>
    <td <?php if($row['date27']==27){ echo 'style="background-color:#090"'; }?>></td>
    <td <?php if($row['date28']==28){ echo 'style="background-color:#090"'; }?>></td>
    <td <?php if($row['date29']==29){ echo 'style="background-color:#090"'; }?>></td>
    <td <?php if($row['date30']==30){ echo 'style="background-color:#090"'; }?>></td>
    <td <?php if($row['date31']==31){ echo 'style="background-color:#090"'; }?>></td>
  </tr>
  <?php }?>
 
 
 
</table>

      
      </div>
      
    
  </div>


 <td class="c-r"></td>
        </tr>
        <tr class="light">
          <td class="b-l"></td>
          <td class="b-c"></td>
          <td class="b-r"></td>
        </tr>
      </tbody></table>